<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>学生成绩-云校通</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart>
	<div class="weui_tab tab-bottom">
		<div class="weui-header bg-blue"> 
	  		<div class="weui-header-left"> <a onclick="back()" href="javascript:" class="icon icon-109 f-white">返回</a> </div>
	    	<h1 class="weui-header-title">学生成绩</h1>
	    </div>
		<div class="weui_tab_bd">
            <div class="weui_panel weui_panel_access">
	            <div class="weui_panel_bd">
					<div class="weui_cells weui_cells_access mt0">
						 <p class="weui_media_desc" style="padding: 20px;line-height: 30px;">
							<b>ABCD等级分数段：</b>
							一二年级A>=90、B>=85、C>=60、D<60<br/>
							三四年级A>=85、B>=80、C>=60、D<60br/>
							五六年级A>=80、B>=75、C>=60、D<60
						 </p>
					</div>
                    <div class="weui_cells weui_cells_access mt0 mb55 pb20" id="scoreList">
                    	
                    </div>
                    
                    <script id="studentScore-table-template" type="text/x-handlebars-template">
		                    {{#each list}}
			                    <div class="weui_cell_bd weui_cell_primary">           
			                   	     <div class="cj_main">
								        <div class="head">
								          <ul>
								            <li>
												<h3>{{examName}}</h3>
												<a href="<%=basePath%>${user.currUrl}/student/groupup/scoreReport/{{examId}}?from=sys&sid=${studentId}" class="score-report">
													<img src="<%=basePath%>/images/huojiangdengji@3x.png" style="height: 18px;"> 成绩分析
												</a>
											</li>
								            <li><span>{{termName}}</span></li>
								          </ul>
								        </div>
								        <div class="body">
								          <ul style="float: left">
								            <li><p>语文</p><span>{{scoreToGradeFormat gradeId chineseScore fullScore 0}}</span></li>
								            <li><p>英语</p><span>{{scoreToGradeFormat gradeId englishScore fullScore 2}}</span></li>
								            <li><p>数学</p><span>{{scoreToGradeFormat gradeId mathScore fullScore 1}}</span></li>
								          </ul>
										  <ul style="float: right">
								          	{{#each scoreAvgList}}
								            	<li><p><b>年级人平均分</b></p><span><b>{{avgScore}}</b></span></li>
								          	{{/each}}
								          </ul>
								        </div>
								      </div>
			                   	</div>
			                {{/each}}
		                    </script>
	            </div>
            </div>
        </div>   
	</div>
</body>
<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
<script>
	$(function() {
		initStudentScore();
	});
	function initStudentScore(){
		$.ajax({
          	url : basePath + "/student/groupup/studentScore/query",
  	 		type : "post",
  	 		dataType : "json",
  	 		data : {
  	 			studentId: "${studentId}"
  	 		},
            success: function(data){
            	if(data != null && data.length > 0) {
            		var result = {list: data};
            		loadStudentScoreHtml(result);
            	}
            },
            error: function(xhr, type){
              
            }
         });
	}
	function loadStudentScoreHtml(data) {
		var myTemplate = Handlebars.compile($("#studentScore-table-template").html());
		Handlebars.registerHelper("equal", function(v1,v2,options) {
			if(v1 == v2) {
				//满足添加继续执行
				return options.fn(this);
			}else {
				//不满足条件执行{{else}}部分
				return options.inverse(this);
			}
		});
		Handlebars.registerHelper("dateFormat", function(v1) {
			return getTime(v1, "yyyy/MM/dd hh:mm");
		});
		Handlebars.registerHelper("scoreToGradeFormat", function(gradeId, score, fullScore, idx) {
			return scoreToGrade(gradeId, score, fullScore, idx);
		});
		$('#scoreList').append(myTemplate(data));
	}
</script>
</html>